// 注册及删除监听事件
export const on = (function() {
    if (document.addEventListener) {
        return function(el, event, handler) {
            el.addEventListener(event, handler, false)
        }
    } else if (document.attachEvent) {
        return function(el, event, handler) {
            el.attachEvent('on' + event, handler)
        }
    } else {
        return function(el, event, handler) {
            el[on + 'event'] = handler
        }
    }
})()
export const off = (function() {
    if (document.removeEventListener) {
        return function(el, event, handler) {
            el.removeEventListener(event, handler, false)
        }
    } else if (document.detachEvent) {
        return function(el, event, handler) {
            el.detachEvent('on' + event, handler)
        }
    } else {
        return function(el, event, handler) {
            el[on + 'event'] = null
        }
    }
})()
// 合并对象,并没有考虑深层次的情况
export const merge = (obj = {}, ...args) => {
    for (let i = 0, len = args.length; i < len; i++) {
        let tempObj = args[i]
        if (tempObj) {
            for (let prop in tempObj) {
                if (tempObj.hasOwnProperty(prop)) {
                    obj[prop] = tempObj[prop]
                }
            }
        }
    }
    return obj
}
